<?php
namespace Admin\Controller;
use Think\Controller;
class UserController extends Controller {
	public function __construct(){
		parent::__construct();
		if(!$_SESSION['admin_is_login']){
			$this->error('还未登录，请登录',U('admin/auth/do_login'));
		}
	}
    public function index(){
    	$user_model = M('user');
    	$count = $user_model->count();
    	$Page = new \Org\Util\Page($count,10);
    	$users = $user_model->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
    	$this->assign('users',$users);
    	$this->assign('page',$Page->show());
        $this->display();
    }
    public function ban($id){
        M('user')->where('id ='.$id)->save(array('status' => '-1'));
        $this->success('禁用成功',U('admin/user/index'));
    }
    public function enable($id){
        M('user')->where('id ='.$id)->save(array('status' => '0'));
        $this->success('启用成功',U('admin/user/index'));
    }
}